Virtual machines (VMs) running on a physical host may use a graphics processing unit (GPU) to perform graphics operations. Virtualization software manages the use of the GPU by the VMs. Each VM runs a guest operating system, which may be a commodity operating system such as Microsoft Windows or Linux, and various virtual devices are presented to the guest operating system by the underlying virtualization software. For example, the virtualization software may present virtual peripheral component interconnect (VPCI) devices to the guest operating system where one of the VPCI devices includes a virtual GPU (or “VGPU”). The VGPU, therefore is a software abstraction of a physical GPU device; the functionality of the VGPU is defined by software routines that form part of the virtualization software as well as any physical devices, such as physical, or host GPUs (or “HGPUs”) and associated drivers, that support the VGPU operation. Virtualization software can be viewed as a layer of indirection, wherein VGPU requests from the VM are received by the virtualization software and redirected to an HGPU, which might also be shared by a number of VMs in a manner that is transparent to each of the VMs.
VGPUs process software function calls from the guest operating system to perform graphics operations using graphics resources. The graphics operations include clearing the display, setting the display mode, rendering a scene, or playing a video frame. The software function calls are directed to VGPU resources that are mapped to HGPU function calls by a process referred to herein as an extended virtual machine (VMX). Typically, each VM running on a host has a corresponding VMX process.
Before using a graphics resource, a VM SVGA guest driver first stores the contents for the graphics resource in guest memory of the VM and sends a “create” graphics object command and a unique graphics object ID to the VGPU. In response to the command from the VM, the VMX process then passes the resource to the HGPU driver which stores the content for the graphics resource in host HGPU memory associated with the HGPU. For example, the virtual machine may use a texture, which applies detail to an item, or a shader, which is a program that is executable by the HGPU for applying rendering effects. The HGPU driver stores image data for the texture or byte code for the shader, along with associated meta data, in HGPU memory for use by the VMs when needed.
Multiple VMs running on the host may use identical graphics resources. For example, multiple VMs may be running the same operating system, which might use the same textures and shaders. However, VMs are generally isolated from one another and do not know which graphics resources are being used by other VMs. Thus, each VM may store content for identical graphics resources in their guest memory. The VMX processes each direct the graphics resources to the HPGU driver which copies the contents for the identical graphics resources in host HGPU memory. Thus, redundant content can be stored in the HGPU memory.